//package aspect;
//
//import java.lang.reflect.Method;
//import java.lang.reflect.Modifier;
//import java.util.Date;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.*;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//import util.JsonUtil;
//
//@Component
//@Aspect
//public class SystemLogAspect {
//    private static Logger log = LoggerFactory.getLogger(SystemLogAspect.class);
//    private long startTime = 0L;
//
//
//    /**
//     * Service层切点
//     */
//    @Pointcut("@annotation(aspect.SystemServiceLog)")
//    public void serviceAspect() {
//
//    }
//
//
//    @Before("serviceAspect()")
//    public void before(JoinPoint joinPoint) {
//        startTime = System.currentTimeMillis();
//        System.out.println(">>>>>>>>>>>>>>>>>>>>>>@Before>>>>>>>>>>>>>>>>>>>>>>>");
//
//
//    }
//
//    @AfterThrowing("serviceAspect()")
//    public void afterThrowing(JoinPoint joinPoint) {
//        System.out.println(">>>>>>>>>>>>>> @AfterThrowing >>>>>>>>>>>>>>>>>>>>>>>>");
//
//    }
//
//    /**
//     * doServiceLog:获取注解参数，记录日志. <br/>
//     *
//     * @param joinPoint 切入点参数
//     * @author lcma
//     * @since JDK 1.7
//     */
//    @AfterReturning("serviceAspect()")
//    public void afterReturning(JoinPoint joinPoint) throws Exception {
//
//
//        log.info("日志记录");
//        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
//        String uri = request.getRequestURI();
//        String ip = request.getRemoteAddr();
//        String httpMethod = request.getMethod();
//        long timeConsume = System.currentTimeMillis() - startTime;
//        String methodName = joinPoint.getSignature().getName();
//        short operateType = -1;//操作表类型 -1不清楚  0新增 1查询  2修改  3删除  4登录 5退出
//        if (methodName.indexOf("recordDeleteLog") > -1) {
//            operateType = 3;
//        } else if (methodName.indexOf("recordUpdateLog") > -1) {
//            operateType = 2;
//        } else if (methodName.indexOf("recordInsertLog") > -1) {
//            operateType = 0;
//        } else {
//            log.error("记录类条 操作类型 未知的记录");
//        }
//
//
//        System.out.println("uri:" + uri);
//        System.out.println("ip:" + ip);
//        System.out.println("httpMethod:" + httpMethod);
//        System.out.println("timeConsume:" + timeConsume);
//        System.out.println("time:" + new Date());
//        System.out.println("tableName:" + getTableName(joinPoint));
//        System.out.println("params:" + getServiceMethodParams(joinPoint));
//        System.out.println("operationType:" + operateType);
//
//
//    }
//
//
//    /**
//     * 获取代理对象表名
//     *
//     * @param joinPoint
//     * @return
//     * @throws Exception
//     */
//    private String getTableName(JoinPoint joinPoint) throws Exception {
//        String targetName = joinPoint.getTarget().getClass().getName();
//        Class targetClass = Class.forName(targetName);
//        Method m = targetClass.getDeclaredMethod("getTableName");
//        String tableName = (String) m.invoke(joinPoint.getTarget());
//        return tableName;
//    }
////
////    /**
////     * getServiceMethodTableType:获取注解中对方法的数据表类型 用于service层注解 . <br/>
////     *
////     * @param joinPoint
////     * @return
////     * @throws Exception
////     * @author lcma
////     * @since JDK 1.7
////     */
////    private int getServiceMethodOperationType(JoinPoint joinPoint) throws Exception {
////        String targetName = joinPoint.getTarget().getClass().getName();
////        String methodName = joinPoint.getSignature().getName();
////        Object[] arguments = joinPoint.getArgs();
////        Class targetClass = Class.forName(targetName);
////        Method[] methods = targetClass.getMethods();
////        int operationType = 0;
////        for (Method method : methods) {
////            if (method.getName().equals(methodName)) {
////                Class[] clazzs = method.getParameterTypes();
////                if (clazzs.length == arguments.length) {
////                    operationType = method.getAnnotation(SystemServiceLog.class).operationType();
////                    break;
////                }
////            }
////        }
////        return operationType;
////    }
//
//    //    /**
////     * getServiceMethodParams:获取json格式的参数. <br/>
////     *
////     * @param joinPoint
////     * @return
////     * @throws Exception
////     * @author lcma
////     * @since JDK 1.7
////     */
//    private String getServiceMethodParams(JoinPoint joinPoint)
//            throws Exception {
//        Object[] arguments = joinPoint.getArgs();
//        String params = JsonUtil.obj2Json(arguments);
//        return params;
//    }
//
//
//
//}